/*
 ***************************************************************************************
 * All rights Reserved, Designed By RTF
 * @Title:  RocketMqCosumerProperties.java   
 * @Package com.rtf.repair.mq.rocketmq.consumer
 * @Description: 消费者属性 
 * @author: 司福林
 * @date:   2020-10-17 17:26:20   
 * @version V1.0 
 * @Copyright: 2020 RTF. All rights reserved.
 * 注意：本内容仅限于公司内部使用，禁止外泄以及用于其他的商业目
 *  ---------------------------------------------------------------------------------- 
 * 文件修改记录
 *     文件版本：         修改人：             修改原因：
 ***************************************************************************************
 */
package com.rtf.framework.mq.rocketmq.consumer;

import lombok.Data;

/**
 * Instantiates a new rocket mq cosumer properties.
 */
@Data
public class RocketMqConsumerProperties {

	/** 启用rocketmq消费 */
	private boolean enable = false;

	/** nameserver 地址 */
	private String namesrvAddr;

	/** 拉去topic信息间隔 */
	private int pollNameServerInterval = 1000 * 30;

	/** 心跳间隔*/
	private int heartbeatBrokerInterval = 1000 * 30;

	/**
	 * Offset persistent interval for consumer
	 */
	private int persistConsumerOffsetInterval = 1000 * 5;

	/**
	 * Minimum consumer thread number
	 */
	private int consumeThreadMin = 20;

	/**
	 * Max consumer thread number
	 */
	private int consumeThreadMax = 64;

	/**
	 * Threshold for dynamic adjustment of the number of thread pool
	 */
	private long adjustThreadPoolNumsThreshold = 100000;

	/**
	 * Concurrently max span offset.it has no effect on sequential consumption
	 */
	private int consumeConcurrentlyMaxSpan = 2000;

	/**
	 * Flow control threshold on queue level, each message queue will cache at most 1000 messages by default,
	 * Consider the {@code pullBatchSize}, the instantaneous value may exceed the limit
	 */
	private int pullThresholdForQueue = 1000;

	/**
	 * Limit the cached message size on queue level, each message queue will cache at most 100 MiB messages by default,
	 * Consider the {@code pullBatchSize}, the instantaneous value may exceed the limit
	 *
	 * <p>
	 * The size of a message only measured by message body, so it's not accurate
	 */
	private int pullThresholdSizeForQueue = 100;

	/**
	 * Flow control threshold on topic level, default value is -1(Unlimited)
	 * <p>
	 * The value of {@code pullThresholdForQueue} will be overwrote and calculated based on
	 * {@code pullThresholdForTopic} if it is't unlimited
	 * <p>
	 * For example, if the value of pullThresholdForTopic is 1000 and 10 message queues are assigned to this consumer,
	 * then pullThresholdForQueue will be set to 100
	 */
	private int pullThresholdForTopic = -1;

	/**
	 * Limit the cached message size on topic level, default value is -1 MiB(Unlimited)
	 * <p>
	 * The value of {@code pullThresholdSizeForQueue} will be overwrote and calculated based on
	 * {@code pullThresholdSizeForTopic} if it is't unlimited
	 * <p>
	 * For example, if the value of pullThresholdSizeForTopic is 1000 MiB and 10 message queues are
	 * assigned to this consumer, then pullThresholdSizeForQueue will be set to 100 MiB
	 */
	private int pullThresholdSizeForTopic = -1;

	/**
	 * Message pull Interval
	 */
	private long pullInterval = 0;

	/**
	 * Batch consumption size
	 */
	private int consumeMessageBatchMaxSize = 1;

	/**
	 * Batch pull size
	 */
	private int pullBatchSize = 32;

	/**
	 * Max re-consume times. -1 means 16 times.
	 * </p>
	 *
	 * If messages are re-consumed more than {@link #maxReconsumeTimes} before success, it's be directed to a deletion
	 * queue waiting.
	 */
	private int maxReconsumeTimes = -1;

	/**
	 * Suspending pulling time for cases requiring slow pulling like flow-control scenario.
	 */
	private long suspendCurrentQueueTimeMillis = 1000;

	/**
	 * Maximum amount of time in minutes a message may block the consuming thread.
	 */
	private long consumeTimeout = 15;
}
